// pages/wallet/wallet.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    typeKey: 0,
    myPackage: {},
    incomeList: [],
    expenditureList: [],
    company: []
  },

  // 选择明细类别
  changeType: function (e) {
    this.setData({
      typeKey: e.currentTarget.dataset.key
    })
  },

  // 代扣个税
  pay: function () {
    wx.navigateTo({
      url: '/pages/pay/pay',
    })
  },

  // 去提现
  cash: function () {
    wx.navigateTo({
      url: '/pages/cash/cash?total=' + this.data.myPackage.total,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#284A6C',
      animation: {
        duration: 400,
        timingFunc: 'easeIn'
      }
    })
    that.setData({
      identity: wx.getStorageSync('identity')
    })
    app.post('Member/myprice', {
      token: wx.getStorageSync('token')
    }).then(res => {
      let list = res.data.result_data
      that.setData({
        myPackage: res.data.result_data,
        incomeList: list.apply,
        expenditureList: list.record,
        company: list.company == undefined ? [] : list.company
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onLoad()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})